import sqlite3
import string
import datetime

con = sqlite3.connect('/home/ben/fridge.db', detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
cur = con.cursor()
f = open('20101006.012213.dat', 'r')
for line in f:
  s = string.split(line)
  if len(s) == 4:
    time = datetime.datetime.fromtimestamp(float(s[0]))
    temp = float(s[2])
    cur.execute('insert into data(time, temperature) values (?, ?)', (time, temp))
    con.commit()
    print time, temp
